/*
 * @Description: enter your description
 * @Autor: 帅ZR帅
 * @Date: 2022-12-21 16:41:57
 * @LastEditors: 帅ZR帅
 * @LastEditTime: 2022-12-28 21:37:22
 */

#ifndef _CAMERA_H_
#define _CAMERA_H_
#include "headfile.h"
/*以下4个模式只能选择1种*/
#define H_2_W_2_Image 0 // 四分一图像 高度宽度同时缩小
#define H_2_W_1_Image 0 // 二分一图像 高度缩小
#define H_1_W_2_Image 0 // 二分一图像 宽度缩小
#define Full_Image    1 // 原图

#define Nucleus 0 //图像腐蚀 核大小 可选 : 0 4 9 , 0就是不开启图像腐蚀

#define Usart_Send_Image  0 //是否发送图像至上位机 0 关闭 1 开启
#define IPS200_Show_Image 1 //是否在屏幕显示图像 0 关闭 1 开启


#define ERROR 2
#define Binary_Threshold_Max 170 // 40
#define Binary_Threshold_Min 100 // 35
#define Find_Line_Down Original_Image_H-10 // BIG
#define Find_Line_Up 10

#if H_2_W_2_Image 
    #define Original_Image_H MT9V03X_H/2
    #define Original_Image_W MT9V03X_W/2
#elif H_2_W_1_Image
    #define Original_Image_H MT9V03X_H/2
    #define Original_Image_W MT9V03X_W
#elif H_1_W_2_Image
    #define Original_Image_H MT9V03X_H
    #define Original_Image_W MT9V03X_W/2
#elif Full_Image
    #define Original_Image_H MT9V03X_H
    #define Original_Image_W MT9V03X_W
#endif


#define Binary_Image_H Original_Image_H
#define Binary_Image_W Original_Image_W


extern uint8_t Binary_Threshold;
extern uint8_t MideLine_Length;

extern uint32_t t0;

extern uint8 Image_Show_Flag;          //图像显示标志位 菜单按键控制 是否开启
extern uint8 Boder_Show_Flag;          //边界显示标志位 菜单按键控制 是否开启

// DMA 接收 摄像头图像 地址
extern uint8_t Original_Image[Original_Image_H][Original_Image_W];
extern uint8_t Binary_Image[Binary_Image_H][Binary_Image_W];
extern uint8_t Test_Image[Binary_Image_H][Binary_Image_W]; // 二维数组先行后列
void Get_Original_Image(void);
void Detect_Threshold(void);
void Otsu_Threshold(void);
void Original_Image_to_Binary_Image(void);
void Canker_Image(void);
void Calculate_MideLine_Length(void);
void Find_Boder(void);

#endif // !_CAMERA_H_